<script type="text/javascript"><!--//--><![CDATA[//><!--

	var grid_reload = function(){
		$('#datagrid').datagrid('reload', $('#fm_search').serializeObject());
	};
	$(document).ready(function() {
		// Setup Datagrid
		$('#datagrid').datagrid({  
			url:gs_path+'/'+controller+'/getdata', 
			queryParams: $('#fm_search').serializeObject(),
			height:340,
			pagination:true,
			columns:[[
				{ field : 'ck', checkbox:true, width: 40, align: 'center' },
				{ field : 'supplier_kode', title : 'Kode Supplier', width : 100, sortable:true },
				{ field : 'supplier_nama', title : 'Nama Supplier', width : 250, sortable:true },
				{ field : 'supplier_alamat', title : 'Alamat Supplier', width : 250, sortable:true },
				{ field : 'supplier_telp', title : 'Telp Supplier', width : 100, sortable:true },
				{ field : 'supplier_email', title : 'Email Supplier', width : 150, sortable:true }
			]]
		});
		
		$('#filter_app_id').setCombo({ data: <?php echo json_encode($arr_application); ?> });
		
		// Setup Form
		$('#form_master').setupForm([
			{ name: 'supplier_kode', type: 'text', size: 'long', maxlength: 250, noempty:true },
			{ name: 'supplier_nama', type: 'text', size: 'long', maxlength: 250, noempty:true },
			{ name: 'supplier_alamat', type: 'text', size: 'long', maxlength: 250, noempty:true },
			{ name: 'supplier_telp', type: 'text', size: 'long', maxlength: 250, noempty:true },
			{ name: 'supplier_fax', type: 'text', size: 'long', maxlength: 250 },
			{ name: 'supplier_email', type: 'text', size: 'long', maxlength: 250 },
			{ name: 'supplier_website', type: 'text', size: 'long', maxlength: 250 },
			{ name: 'supplier_npwp', type: 'text', size: 'long', maxlength: 250 },
			{ name: 'supplier_npwp_pengukuhan', type: 'text', size: 'long', maxlength: 250 },
			{ name: 'supplier_siup', type: 'text', size: 'long', maxlength: 250 },
			{ name: 'supplier_situ', type: 'text', size: 'long', maxlength: 250 },			
			{ name: 'supplier_ijin_depkes', type: 'text', size: 'long', maxlength: 250 },
			{ name: 'supplier_ijin_date', type: 'date'},
			{ name: 'supplier_pkp', type: 'text', size: 'long', maxlength: 250 },
			{ name: 'supplier_nokontrak', type: 'text', size: 'long', maxlength: 250 },
			{ name: 'supplier_kontrak_awal', type: 'text', size: 'long', maxlength: 250 },
			{ name: 'supplier_kontrak_akhir', type: 'text', size: 'long', maxlength: 250 },
			{ name: 'supplier_konsinyasi', type: 'text', size: 'long', maxlength: 250 },
			{ name: 'supplier_aktif', type: 'text', size: 'long', maxlength: 250 },
			{ name: 'supplier_jatuh_tempo', type: 'date'}
		]);

		// Create Dialog
		$('#dialog_container').dialog({
			closed:true,
			modal:true,
			title: '_',
			width:600,
			buttons:[{
				text:'Save',
				iconCls:'icon-save',
				handler:function(){
					$('#form_master').submitForm('/'+controller+'/ajax_post', { onComplete : function(){ $('#dialog_container').dialog('close'); $('#datagrid').datagrid('reload'); }} );					
				}
			},{
				text:'Close',
				iconCls:'icon-cancel',
				handler:function(){
					$('#dialog_container').dialog('close');
				}
			}]
		});		
		
		// Set Action Button
		var buttons = [ { label: 'Add', icon: 'add', onclick: function() {
							resetError();
							$('#dialog_container').dialog('open');
							$('#form_master').data('mode', 'create');
							$('#form_master').parent().parent().parent().prev().find('.panel-title').html('New Supplier');
							$('#supplier_kode').readonly(false);
							$('#supplier_nama').readonly(false);
							$('#supplier_alamat').readonly(false);
							$('#supplier_telp').readonly(false);
							$('#supplier_fax').readonly(false);							
							$('#supplier_email').readonly(false);
							$('#supplier_website').readonly(false);
							$('#supplier_npwp').readonly(false);
							$('#supplier_npwp_pengukuhan').readonly(false);
							$('#supplier_siup').readonly(false);
							$('#supplier_situ').readonly(false);
							$('#supplier_ijin_depkes').readonly(false);
							$('#supplier_ijin_date').readonly(false);
							$('#supplier_pkp').readonly(false);
							$('#supplier_nokontrak').readonly(false);							
							$('#supplier_kontrak_awal').readonly(false);
							$('#supplier_kontrak_akhir').readonly(false);
							$('#supplier_konsinyasi').readonly(false);
							$('#supplier_aktif').readonly(false);
							$('#supplier_jatuh_tempo').readonly(false);							
							$('#supplier_kode').focus();
						} },
						{ label: 'Edit', icon: 'edit', onclick: function() {
							var oSel=$('#datagrid').datagrid('getSelected'); 
							if(oSel==null){ alert('Please select row!'); }
							else{ 
								resetError();
								$('#dialog_container').dialog('open'); 
								$('#form_master').data('mode', 'edit');
								$('#form_master').parent().parent().parent().prev().find('.panel-title').html('Edit Supplier');
								$('#supplier_kode').readonly();
								jsonToForm(oSel); 
								$('#supplier_nama').focus();
							} 
						} },
						{label: 'Delete', icon: 'delete', onclick: function() { 
							var oSel = $('#datagrid').datagrid('getSelected'); 
							if (oSel == null) { 
								$.messager.alert('&nbsp;', gs_msg_row_unselected, 'warning'); 
							} else { 
								deleteData(['supplier_kode']);
							} 
						}}];
		setAction(buttons);
		
		
		$('#fm_search').focusFirst();
	});
//--><!]]></script>

<div id="tb" style="padding:5px;height:auto">
    <div>
        <form id="fm_search" onsubmit="grid_reload(); return false;">
        	<table class="tb_form" style="margin-bottom:0px">

            <tr>
            	<td width="100">Keyword</td>
                <td><input type="text" id="keyword" name="keyword" class="textfield medium" />
                	<a href="#" class="easyui-linkbutton" iconCls="icon-search" onclick="grid_reload(); return false;">Search</a>
                </td>
            </tr>
            </table>
        </form>
    </div>
</div>
<div id="datagrid" toolbar="#tb"></div>

<div id="dialog_container" style="padding:5px;width:600px;height:250px;">
	<form id="form_master">
    <table class="tb_form" style="width:100%;" cellpadding="0" cellspacing="0">    
    <tr>
        <td class="label">Kode Supplier</td>
        <td><input id="supplier_kode" /></td>
    </tr>
    <tr>
        <td class="label">Nama Supplier</td>
        <td><input id="supplier_nama" /></td>
    </tr>
    <tr>
        <td class="label">Alamat Supplier</td>
        <td><input id="supplier_alamat" /></td>
    </tr>
    <tr>
        <td class="label">Telp Supplier</td>
        <td><input id="supplier_telp" /></td>
    </tr>
    <tr>
        <td class="label">Fax Supplier</td>
        <td><input id="supplier_fax" /></td>
    </tr>	
	<tr>
        <td class="label">Email Mdstruktur</td>
        <td><input id="supplier_email" /></td>
    </tr>
    <tr>
        <td class="label">Website Supplier</td>
        <td><input id="supplier_website" /></td>
    </tr>
    <tr>
        <td class="label">NPWP Supplier</td>
        <td><input id="supplier_npwp" /></td>
    </tr>
    <tr>
        <td class="label">NPWP Pengukuhan Supplier</td>
        <td><input id="supplier_npwp_pengukuhan" /></td>
    </tr>
    <tr>
        <td class="label">Siup Supplier</td>
        <td><input id="supplier_siup" /></td>
    </tr>
    <tr>
        <td class="label">Situ Supplier</td>
        <td><input id="supplier_situ" /></td>
    </tr>
	<tr>
        <td class="label">Ijin Depkes Supplier</td>
        <td><input id="supplier_ijin_depkes" /></td>
    </tr>	
	<tr>
        <td class="label">Tanggal Ijin Supplier</td>
        <td><input id="supplier_ijin_date" /></td>
    </tr>	
	<tr>
        <td class="label">PKP Supplier</td>
        <td><input id="supplier_pkp" /></td>
    </tr>
    <tr>
        <td class="label">No Kontrak Supplier</td>
        <td><input id="supplier_nokontrak" /></td>
    </tr>
    <tr>
        <td class="label">Kontrak Awal Supplier</td>
        <td><input id="supplier_kontrak_awal" /></td>
    </tr>
    <tr>
        <td class="label">Kontrak Akhir Supplier</td>
        <td><input id="supplier_kontrak_akhir" /></td>
    </tr>
    <tr>
        <td class="label">Konsinyasi Supplier</td>
        <td><input id="supplier_konsinyasi" /></td>
    </tr>
    <tr>
        <td class="label">Aktif Supplier</td>
        <td><input id="supplier_aktif" /></td>
    </tr>
	<tr>
        <td class="label">Jatuh Tempo Supplier</td>
        <td><input id="supplier_jatuh_tempo" /></td>
    </tr>
    </table>
	</form>  
    
</div>
